package com.venus.plan.planaction.service.impl;

import java.util.List;

import com.venus.common.service.impl.BaseServiceImpl;
import com.venus.common.utils.ConditionUtil;
import com.venus.component.page.PageInfo;
import com.venus.model.PlanActionVO;
import com.venus.model.PubUserVO;
import com.venus.plan.planaction.dao.IPlanActionDAO;
import com.venus.plan.planaction.service.IPlanActionService;

public class PlanActionServiceImpl extends BaseServiceImpl implements
		IPlanActionService {

	private IPlanActionDAO planActionDAO;
	
	public void setPlanActionDAO(IPlanActionDAO planActionDAO){this.planActionDAO = planActionDAO;}
	
	public PageInfo getPageInfo(int iPageRecord, int iCurPage, List<ConditionUtil> lstConditionUtils) {
		String strCountHql = "select count(PlanActionVO.planActionId) from PlanActionVO as PlanActionVO where 1=1";
		String strRecordHql = "from PlanActionVO where 1=1";
		return this.planActionDAO.getPageInfo(strCountHql, strRecordHql, lstConditionUtils, iPageRecord, iCurPage);
	}

	public void deletePlanActionVO(String[] strPlanActionIds) {
		for(String strPlanActionId : strPlanActionIds){
			// 删除PlanAction实例
			this.planActionDAO.delete("delete from PlanActionVO where planActionId=?", Integer.parseInt(strPlanActionId));
		}
	}

	@SuppressWarnings("unchecked")
	public List<PlanActionVO> findPlanActionVOByUser(PubUserVO objPubUserVO) {
		return this.planActionDAO.find("from PlanActionVO where pubUser=? order by createDate", objPubUserVO);
	}

	public PlanActionVO loadPlanActionVO(Integer iPlanActionId) {
		return this.planActionDAO.getModel(PlanActionVO.class, iPlanActionId);
	}

	public void saveOrUpdatePlanActionVO(PlanActionVO objPlanActionVO) {
		this.planActionDAO.saveOrUpdateModel(objPlanActionVO);
	}

	public void savePlanActionVO(PlanActionVO objPlanActionVO) {
		this.planActionDAO.saveModel(objPlanActionVO);
	}
}
